<?php

namespace app\common\model;

use think\Model;
use traits\model\SoftDelete;

class Introduce extends Model
{
    //软删除
    use SoftDelete;

    //留学生在日高考优势
    public function introduce_list($data)
    {
        $validate = new \app\common\validate\Introduce();
        if (!$validate -> scene('list') -> check($data)){
            return $validate -> getError();
        }
        $in = $this -> find($data['id']);
        $in -> title = $data['title'];
        $in -> content = $data['content'];
        $result = $in -> save();
        if ($result){
            return 1;
        } else {
            return '更新失败！';
        }
    }

    //留学费用
    public function introduce_cost($data)
    {
        $validate = new \app\common\validate\Introduce();
        if (!$validate -> scene('list') -> check($data)){
            return $validate -> getError();
        }
        $in = $this -> find($data['id']);
        $in -> title = $data['title'];
        $in -> content = $data['content'];
        $result = $in -> save();
        if ($result){
            return 1;
        } else {
            return '更新失败！';
        }
    }

    //日本就业
    public function introduce_job($data)
    {
        $validate = new \app\common\validate\Introduce();
        if (!$validate -> scene('edit') -> check($data)){
            return $validate -> getError();
        }
        $in = $this -> find($data['id']);
        $in -> title = $data['title'];
        $in -> author = $data['author'];
        $in -> content = $data['content'];
        $result = $in -> save();
        if ($result){
            return 1;
        } else {
            return '更新失败！';
        }
    }

    //全局展望
    public function introduce_look($data)
    {
        $validate = new \app\common\validate\Introduce();
        if (!$validate -> scene('edit') -> check($data)){
            return $validate -> getError();
        }
        $in = $this -> find($data['id']);
        $in -> title = $data['title'];
        $in -> author = $data['author'];
        $in -> content = $data['content'];
        $result = $in -> save();
        if ($result){
            return 1;
        } else {
            return '更新失败！';
        }
    }

}
